package com.teatime.client.net.http;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

@SuppressWarnings("unused")
public class FormFile {
    private File mFile;
	private String mFilePath;
    private String mFileName;
    private String mContentType = "application/octet-stream";
    private InputStream mInStream;
    
    public FormFile(String filePath, String contentType) throws FileNotFoundException{
    	this(filePath, new File(filePath), contentType);
    }
    
    public FormFile(File file, String contentType) throws FileNotFoundException {
    	this(file.getPath(), file, contentType);
    }
    
    public FormFile(String filePath) throws FileNotFoundException{
    	this(filePath, null);
    }
    
    public FormFile(File file) throws FileNotFoundException {
    	this(file, null);
    }
    
    private FormFile(String filePath, File file, String contentType) throws FileNotFoundException {
    	mFilePath = filePath;
        mFile = file;
        mFileName = mFile.getName();
        if(contentType != null) {
        	mContentType = contentType;
        }
        else {
        	mContentType = MIMEUtils.getMIMEType(mFileName);
        }
        mInStream = new FileInputStream(mFile);
    }
    
    public File getFile() {
        return mFile;
    }

    public String getFileName() {
        return mFileName;
    }

    public void setFileName(String fileName) {
        mFileName = fileName;
    }

    public String getContentType() {
        return mContentType;
    }

    public void setContentType(String contentType) {
        mContentType = contentType;
    }
    
    public InputStream getInputStream() {
   		return mInStream;
    }
}

